package com.future.bantang.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.future.bantang.R;
import com.future.bantang.app.BanTangAPP;
import com.nostra13.universalimageloader.core.ImageLoader;

/**
 * Created by liufujie on 16-1-12.
 *
 * 组合控件（imageview， textview, textview）
 */
public class RoundPicText extends LinearLayout{

    CircleImageView ivPhoto;
    TextView tvTitle;
    TextView tvSubTitle;

    public RoundPicText(Context context) {
        super(context);
    }

    public RoundPicText(Context context, AttributeSet attrs) {
        super(context, attrs);

        LayoutInflater inflater = LayoutInflater.from(context);

        inflater.inflate(R.layout.square_pic_layout, this);

        ivPhoto = (CircleImageView) findViewById(R.id.iv_square_photo);
        tvTitle = (TextView) findViewById(R.id.tv_square_title);
        tvSubTitle = (TextView) findViewById(R.id.tv_square_sub_title);
    }

    /**
     * 设置显示图片
     * @param url
     */
    public void setIvPhoto(String url){
        ImageLoader imageLoader = BanTangAPP.getApp().getImageLoader();
        imageLoader.displayImage(url, ivPhoto);
    }

    /**
     * 设置显示标题
     * @param title
     */
    public void setTvTitle(String title){
        tvTitle.setText(title);
    }

    /**
     * 设置显示副标题
     * @param subTitle
     */
    public void setTvSubTitle(String subTitle){
        tvSubTitle.setText(subTitle);
    }
}
